package cn.edu.cqut.mdm.core.module;

import java.io.Serializable;
import java.util.List;
import java.util.Random;

import cn.edu.cqut.mdm.core.invoker.Invoker;
import cn.edu.cqut.mdm.core.publisherdispatcher.PublisherDispatcher;

public class RemoteModuleEntity implements Serializable{
	/**
	 * 
	 */
	private static final long serialVersionUID = 8486061723197380588L;
	
	private String uid;
	private String name;
	private List<RemoteMethod> methods;
	private String publisherDispatcherName;
	private String url;
	private transient Invoker invoker = new Invoker(this);
	private transient PublisherDispatcher publisherDispatcher;
	private transient boolean disabled;
	private transient int randomId = new Random(System.currentTimeMillis()).nextInt();
	
	public <T> T invoke(Class<T> requiredType, RemoteMethod method, Object... params) {
		return (T) this.invoke(method, params);
	}
	public Object invoke(RemoteMethod method, Object... params) {
		return this.invoker.invoke(method, params);
	}
	public String getUid() {
		return uid;
	}

	public void setUid(String uid) {
		this.uid = uid;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public List<RemoteMethod> getMethods() {
		return methods;
	}

	public void setMethods(List<RemoteMethod> methods) {
		this.methods = methods;
	}
	public PublisherDispatcher getPublisherDispatcher() {
		return publisherDispatcher;
	}
	public void setPublisherDispatcher(PublisherDispatcher publisherDispatcher) {
		this.publisherDispatcher = publisherDispatcher;
	}
	public String getPublisherDispatcherName() {
		return publisherDispatcherName;
	}
	public void setPublisherDispatcherName(String publisherDispatcherName) {
		this.publisherDispatcherName = publisherDispatcherName;
	}
	public String getUrl() {
		return url;
	}
	public void setUrl(String url) {
		this.url = url;
	}
	public boolean isDisabled() {
		return disabled;
	}
	public void setDisabled(boolean disabled) {
		this.disabled = disabled;
	}
	public int getRandomId() {
		return randomId;
	}
}
